set more off
capture log close
cd *** Fill in path name here ***

//  program:    AnanatEtAl_income-college attenance gradient results
//  task:		Regressions of income-colleage attendance gradient on job loss ages 12-17

log using *** Fill in file name here ***, replace text

**** ALL CHILDREN ****; 
// #1
// Load data
use AnanatEtAl_income_college_data.dta, clear

// #2
// Run IV regressions of income-college gradient on job losses
// Weighted by number of children and total black population
ivreg2 collegeage19slope stated1-stated51 yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=numberofchildren], cluster (stateno) first

ivreg2 incomeage26slope stated1-stated51 yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=tot_black], cluster (stateno) first

// #3
// Generate indicator for above-median state unemployment at age 11
gen highunempcoll=unemp_rate>=4.8
gen highunempcoll11 = L6.highunempcoll


// #4
// Run IV regressions of income-college gradient on job losses, by high/low state unemployment at age 11
// Weighted by number of children and total black population

*#children weights

ivreg2 collegeage19slope stated* yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=numberofchildren] if highunempcoll11==1, cluster (stateno) 

ivreg2 collegeage19slope stated* yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=numberofchildren] if highunempcoll11==0, cluster (stateno) 


*#AfAm weights

ivreg2 collegeage19slope stated* yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=tot_black] if highunempcoll11==1, cluster (stateno) 

ivreg2 collegeage19slope stated* yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=tot_black] if highunempcoll11==0, cluster (stateno) 

// #5
// Generate indicator for above-median in-state college tuition at age 11
gen highmedrealtuitioncoll=medrealtuition>= 4097.003  
gen highmedrealtuitioncoll11 = L6.highmedrealtuitioncoll

// #6
// Run IV regressions of income-college gradient on job losses, by high/low state college tuition at age 11
// Weighted by number of children and total black population

*#children weights

ivreg2 collegeage19slope stated* yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=numberofchildren] if highmedrealtuitioncoll11==1, cluster (stateno) 

ivreg2 collegeage19slope stated* yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=numberofchildren] if highmedrealtuitioncoll11==0, cluster (stateno) 


*#AfAm weights

ivreg2 collegeage19slope stated* yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=tot_black] if highmedrealtuitioncoll11==1, cluster (stateno) 

ivreg2 collegeage19slope stated* yeard* (JL_lagged1217sep = JL_lagged1217tic) [fw=tot_black] if highmedrealtuitioncoll11==0, cluster (stateno) 

// #7
// Generate job loss variables at age 20
*Declare the data panel:
xtset stateno year

gen JL_lagged20sep=F3.seppctyr
gen JL_lagged20tic=F3.ticpctyr

// #8
// Run IV regressions of income-college gradient on job losses at age 20 - falsification check
// Weighted by number of children and total black population

ivreg2 collegeage19slope stated1-stated51 yeard* (JL_lagged20sep = JL_lagged20tic) [fw=numberofchildren], cluster (stateno) 

ivreg2 collegeage19slope stated1-stated51 yeard* (JL_lagged20sep = JL_lagged20tic) [fw=tot_black], cluster (stateno) 


clear

log close
